<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: advanced_search.php 354 2013-10-19 10:45:33Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 354 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-10-19 10:45:33 +0000 (Sat, 19 Oct 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

include ('includes/application_top.php');

$smarty = new Smarty();

require (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');

require_once(DIR_FS_INC.'inc.get_categories.php');
require_once(DIR_FS_INC.'inc.get_brand.php');

$breadcrumb->add(NAVBAR_TITLE_ADVANCED_SEARCH, href_link(FILENAME_ADVANCED_SEARCH));

$overlay = true;
require(DIR_WS_INCLUDES.'header.php');

if(SITE_OVERLAYS == 'true')
	$smarty->assign('HELP_LINK', '<a title="'.NAVBAR_TITLE_ADVANCED_SEARCH.'" href="'.href_link(FILENAME_POPUP_SEARCH_HELP, 'iframe=true', 'NONSSL').'" class="shipping">Hilfe</a>');
else
	$smarty->assign('HELP_LINK', '<a title="'.NAVBAR_TITLE_ADVANCED_SEARCH.'" href="javascript:popupWindow(\''.href_link(FILENAME_POPUP_SEARCH_HELP).'\')">Hilfe</a>');

$smarty->assign('FORM_ACTION', draw_form('advanced_search', href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'onsubmit="return check_form(this);"'));

$smarty->assign('INPUT_KEYWORDS', draw_input_field('keywords', '', 'style="width: 100%"'));

$smarty->assign('BUTTON_SUBMIT', image_submit('button_search.gif', IMAGE_BUTTON_SEARCH));

$smarty->assign('SELECT_CATEGORIES',draw_pull_down_menu('categories_id', array_merge(array(array ('id' => '', 'text' => TEXT_ALL_CATEGORIES)), get_categories(0, 1, '', true))));
$smarty->assign('ENTRY_SUBCAT',draw_checkbox_field('inc_subcat', '1', true));
$smarty->assign('SELECT_BRAND',draw_pull_down_menu('brand_id', get_brand(array (array ('id' => '', 'text' => TEXT_ALL_BRAND)))));
$smarty->assign('SELECT_PFROM',draw_input_field('pfrom'));
$smarty->assign('SELECT_PTO',draw_input_field('pto'));

$error = '';
if (isset($_GET['errorno'])) {
	if (($_GET['errorno'] & 1) == 1)
		$error .= str_replace('\n', '<br />', JS_AT_LEAST_ONE_INPUT);
	if (($_GET['errorno'] & 10) == 10)
		$error .= str_replace('\n', '<br />', JS_INVALID_FROM_DATE);
	if (($_GET['errorno'] & 100) == 100)
		$error .= str_replace('\n', '<br />', JS_INVALID_TO_DATE);
	if (($_GET['errorno'] & 1000) == 1000)
		$error .= str_replace('\n', '<br />', JS_TO_DATE_LESS_THAN_FROM_DATE);
	if (($_GET['errorno'] & 10000) == 10000)
		$error .= str_replace('\n', '<br />', JS_PRICE_FROM_MUST_BE_NUM);
	if (($_GET['errorno'] & 100000) == 100000)
		$error .= str_replace('\n', '<br />', JS_PRICE_TO_MUST_BE_NUM);
	if (($_GET['errorno'] & 1000000) == 1000000)
		$error .= str_replace('\n', '<br />', JS_PRICE_TO_LESS_THAN_PRICE_FROM);
	if (($_GET['errorno'] & 10000000) == 10000000)
		$error .= str_replace('\n', '<br />', JS_INVALID_KEYWORDS);

} elseif(isset($_SESSION['error_msg'])) {
	$error = urldecode($_SESSION['error_msg']);
	unset($_SESSION['error_msg']);
}

$smarty->assign('error', $error);
$smarty->assign('language', $_SESSION['language']);
$smarty->assign('FORM_END', '</form>');

$smarty->caching = false;

$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/advanced_search.html');
$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $main_content);
$smarty->caching = false;
if (!defined('RM'))
	$smarty->loadFilter('output', 'note');
$smarty->loadFilter('output','trimwhitespace');
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');
